<?php
require_once("../includes/config.inc.php");
include("./fckeditor/fckeditor.php") ;
validate_admin();

$templateId = $_REQUEST['templateId'];

if($_POST)
{
	@extract($_POST);
	//$pageContent = $pageContent;
	if($templateId)
	{
		
		// Edit Code
		$sqlEdit = " update tbl_nl_template set 
					 templateName = '$templateName',
					 subject = '$subject',
					 adminEmail = '$adminEmail',
					 message = '$message'
					where templateId = '$templateId'
					";	
		
		executeQuery($sqlEdit);
		
		$_SESSION['sessMsg'] = " Template Detail Edited Successfully. ";
		header("location: nlTemplateManager.php");
		exit();
	}
	else
	{
		// Add Code
		$sqlPA = " insert into tbl_nl_template  
		(
		templateName,
		subject,
		adminEmail,
		message
		)
		values
		(
		'$templateName',
		'$subject',
		'$adminEmail',
		'$message'
		)
		";
		executeQuery($sqlPA);
		
		$_SESSION['sessMsg'] = " New Template Added Successfully. ";
		header("location: nlTemplateManager.php");
		exit();
	}
}

if($templateId)
{
	$sqlPD = " select * from tbl_nl_template where templateId = '$templateId' ";
	$resPD = executeQuery($sqlPD);
	if($rowPD = mysql_fetch_array($resPD))
	{
		@extract($rowPD);
	}
}
?>